#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
using namespace std;

vector <long> numStack;

int handleCmd(char cmd[], int &returnVal) {
  string s(cmd);
  if (s.substr(0, 4) == "PUSH") {
    s.erase(0, 4);
    //cout << "S is " << s << endl;
    long j = (long)atoi(s.c_str());
    numStack.push_back(j);
    returnVal = -1;
    return 0;
  }
  else if (s.substr(0, 4) == "SIZE") {
    returnVal = numStack.size();
    return 0;
  }
  else if (s.substr(0, 3) == "POP") {
    returnVal = numStack.back();
    numStack.pop_back();
    return 0;
  }
  else if (s.substr(0, 9) == "REMOVEALL") {
    returnVal = 0;
    s.erase(0, 9);
    long j = (long)atoi(s.c_str());
    cout << "Removing all instances of " << j << endl;
    for (int i=0; i<(int)numStack.size(); i++) {
      cout << i;
      if (numStack[i] == j) {
	numStack.erase(numStack.begin()+(i-1));
	returnVal++;
	cout << ": Found one.";
      }
      cout << endl;
    }
    return 0;
  }
  
  return -1;
  
}


int main() {
  
  while (1) {
    int returnVal;
    string s;
    getline(cin, s);
    if (handleCmd((char*)s.c_str(), returnVal) != 0)
      cout << "Command unrecognized:\t" << s << endl;
    else
      cout << "Return Val:\t" << returnVal << endl;
  }
  return 0;
}
